//
// Created by guanyicheng on 2022/4/6.
//
#include "../../common.h"

class Solution {
public:
    string reverseStr(string s, int k) {
        int i = 0;
        while (i < s.size()) {
            int left = i, right = i + k - 1;
            if (right > s.size() - 1) {
                right = s.size() - 1;
            }
            while (left < right) {
                char t = s[left];
                s[left] = s[right];
                s[right] = t;
                ++left;
                --right;
            }
            i += 2 * k;
        }
        return s;
    }
};